package ld.oauth.blog.utils;

import ld.oauth.blog.model.po.user.SysUser;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;

public class CurrentUser {


    public static   SysUser getCurrentUser() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if(principal !=null&&principal instanceof UserDetails){
            SysUser sysUser = (SysUser)principal;
           return sysUser;
        }
        return null;
    }


}
